import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * service 弹性域模型
 * @date: 2019-4-25

s
 */
import request from 'utils/request';
import { CPAAS_PLATFORM } from 'utils/config';
import { getCurrentOrganizationId } from 'utils/utils';
var organizationId = getCurrentOrganizationId();
/**
 * 个性化明细列表
 * @async
 * @function queryPersonalityDetails
 * @param {object} 个性化明细列表 - 查询条件
 * @returns {object} fetch Promise
 */

export function queryPersonalityDetails(_x) {
  return _queryPersonalityDetails.apply(this, arguments);
}
/**
 * 创建个性化明细
 * @async
 * @function savePersonalityDetails
 * @param {object} params - 保存数据
 * @returns {object} fetch Promise
 */

function _queryPersonalityDetails() {
  _queryPersonalityDetails = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(personalityCode) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/personality-details/").concat(personalityCode)));

          case 1:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryPersonalityDetails.apply(this, arguments);
}

export function savePersonalityDetails(_x2, _x3) {
  return _savePersonalityDetails.apply(this, arguments);
}

function _savePersonalityDetails() {
  _savePersonalityDetails = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(personalityCode, scope) {
    var data,
        _args2 = arguments;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            data = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
            return _context2.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/personality-details/").concat(scope, "/").concat(personalityCode), {
              method: 'POST',
              body: data
            }));

          case 2:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _savePersonalityDetails.apply(this, arguments);
}